Skip to content

fix(provider): advertise forced tools for embedded-MTP Qwen3.8 - #1527

Merged
Gajesh2007 merged 2 commits into
Layr-Labs:masterfrom
javiech1:fix/qwen38-mtp-forced-tools
Oct 21, 2026
Merged

Gajesh2007 merged 2 commits into
Layr-Labs:masterfrom
javiech1:fix/qwen38-mtp-forced-tools

Conversation

@javiech1

@javiech1 javiech1 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

OpenRouter lists Darkbloom's Qwen3.8 27B endpoint with supports_tool_choice: {required: false, function: false}, while 16 of the 20 providers for that model support both. Requests that force a tool (common in agent frameworks) therefore can't use Darkbloom. This covers the Qwen3.8 part of #759.

The provider already enforces forced calls for Qwen3.8 (structuredPostValidation), but two gates still assume the original build:

  1. ToolChoiceEnforcementPolicy.advertisesCapability matched only EigenLabs/Qwen3.8-27B-4bit. Since feat(provider): MTP policy lives in the weights — auto activates embedded Qwen heads only #777 the catalog serves EigenLabs/Qwen3.8-27B-4bit-mtp (same target bytes, embedded head; it is the only active Qwen3.8 entry), so no Mac puts Qwen3.8 in tool_constraint_models. It now uses ModelRuntimeRequirements.qwen38ConcreteModelIDs, which already covers both builds.
  2. validateParser accepted only .xmlFunction/.nemotron for qwen3_5, but the catalog's runtime default is tool_call_parser: qwen3_5 (.qwen35, also what ToolCallFormat.infer picks for this model type). Once routed, a forced request would fail as an invalid request. .qwen35 is now accepted for the Qwen 3.5 family, as it already is for Qwen4 and Bonsai; calls remain withheld until name/schema/cardinality validation.

Diff: 2 source lines changed, 1 constant removed, 2 test lines.

Before / After

flowchart LR
  classDef bad fill:#fde2e2,stroke:#c62828,color:#3b0d0d
  classDef good fill:#e3f4e8,stroke:#2e7d32,color:#0d2b14
  classDef neutral fill:#e3ecfa,stroke:#1565c0,color:#0b2140
  subgraph Before
    B0["Mac serving Qwen3.8-27B-4bit-mtp"]:::neutral --> B1["tool_constraint_models: []"]:::bad
    B2["tool_choice required/named<br/>parser qwen3_5 (catalog default)"]:::neutral --> B3["invalid request"]:::bad
  end
  subgraph After
    A0["Mac serving Qwen3.8-27B-4bit-mtp"]:::neutral --> A1["tool_constraint_models: [..-mtp]"]:::good
    A2["tool_choice required/named<br/>parser qwen3_5"]:::neutral --> A3["withheld, schema-validated call"]:::good
  end
Loading

Evidence

M5 Max 128 GB, EigenLabs/Qwen3.8-27B-4bit-mtp, temperature 0, two declared tools (get_weather, get_time), prompt "What is the weather in Boston?":

tool_choice, parser qwen3_5 master this PR
required invalidToolPayload (parser) get_weather({"city":"Boston"})
{"function":{"name":"get_time"}} invalidToolPayload (parser) get_time({"city":"Boston"})

Measured with a throwaway live test through MLXOpenAIService + production bundle (not committed). The same two requests against the released 0.9.22 provider's local endpoint succeed with tool_call_parser: qwen3_coder and fail with qwen3_5, which matches the parser gate.

Validation

cd provider-swift && swift build --build-tests
swift test --skip-build --filter 'NativeModelToolChoiceTests|NativeToolCapabilityAdvertisementTests|CoordinatorClientTests|ToolChoice|ToolConstraint'
cd .. && make docs-impact-check BASE=origin/master && make docs-check && python3 scripts/changelog.py check

130 tests pass; registrationAdvertisesNativeAndPreservesLegacyContracts and nativeQwenParserAcceptanceDoesNotBroadenOtherFamilies fail on master with the updated fixtures.

Known limitations

  • Coordinator routing and the OpenRouter listing flags are outside this repo; once Macs advertise the model, the listing may still need required/function enabled.
  • Forced tools on Qwen3.8 media requests stay refused (supportsForcedMedia is unchanged).

🤖 Generated with Claude Code

https://claude.ai/code/session_01CDrGQJwa1LC3j4TE6Dvgmo


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

The tool-constraint advertisement still matched only the original
EigenLabs/Qwen3.8-27B-4bit id. The catalog now serves the embedded-MTP
build (same target bytes), so no Mac advertised required/named
tool_choice for Qwen3.8 and the coordinator could not route those
requests to it.

Forced calls on qwen3_5 also rejected the .qwen35 parser that the model
type infers and the catalog sets as its default, so a routed request
would have failed as an invalid request. Accept it as Qwen4 and Bonsai
already do; calls stay withheld until schema validation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CDrGQJwa1LC3j4TE6Dvgmo
@vercel

vercel Bot commented Oct 21, 2026

Copy link
Copy Markdown

@javiech1 is attempting to deploy a commit to the EigenLabs Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Threat model review — advisory

Reviewed head 140e7d118580 against base eaaf5e6156fa.

Reviewers: anthropic/claude-sonnet-5.5: first pass completed; anthropic/claude-opus-5.5: not needed by escalation policy; openai/gpt-6.1-sol: not needed by escalation policy

No actionable findings in the reviewed text. This is not a security approval.

Models: budgeted Sonnet / selective Opus / selective Sol 6.1. Findings require human validation; this review never requests changes or blocks merging.

Coverage: 25/25 source units; cross-file integration complete. 0 selected depth batch(es) pending. All threat definitions indexed; relevant full definitions selected. Unchanged callers are not scanned.

Cost this run: $0.3678 reported, $0.0000 reserved with unknown cost; 5 paid request(s), 0 reused batch(es), 47084 provider cache-hit tokens.

Saved findings and earlier report · Historical findings are not confirmed resolved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CDrGQJwa1LC3j4TE6Dvgmo
@Gajesh2007
Gajesh2007 merged commit 8ad44ba into Layr-Labs:master Oct 21, 2026
2 of 7 checks passed
jonathan308 added a commit that referenced this pull request Oct 21, 2026
Brings #1519 (SSD checkpoint restore staging docs/tests; the same merged SDK pins as this branch, plus libs/mlx ad4745a2) and #1527 (Qwen3.8 forced tools). Conflicts were the Last updated stamps of docs/architecture/hardware-support.md and prefix-cache.md (master's date kept). No GLM code changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants